﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Net.Chirash.Twitter.TwitterDatabase
{
    /// <summary>
    /// TwitterAPIがデータの基底クラス。
    /// </summary>
    public abstract class TwitterData
    {

    }

    #region User
    public partial class User : TwitterData, IEquatable<User>
    {
        #region Public Static Methods

        public static bool operator ==(User A, User B)
        {
            if (ReferenceEquals(A, B))
                return true;
            else if ((object)A == null || (object)B == null)
                return false;
            else
                return (A.UserID == B.UserID);
        }
        public static bool operator !=(User A, User B) { return !(A == B); }

        #endregion

        #region Public Methods

        public bool Equals(User other)
        {
            return (this == other);
        }

        public override int GetHashCode()
        {
            return this.UserID.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            var user = obj as User;
            if (user == null)
                return false;
            else
                return this == user;
        }

        public override string ToString()
        {
            return string.Format("UserID:{0} ScreenName:{1}", this.UserID, this.ScreenName);
        }

        #endregion

    }
    #endregion

    #region Status
    public partial class Status : TwitterData, IEquatable<Status>
    {
        #region Public Static Methods

        public static bool operator ==(Status A, Status B)
        {
            if (ReferenceEquals(A, B))
                return true;
            else if ((object)A == null || (object)B == null)
                return false;
            else
                return (A.StatusID == B.StatusID);
        }
        public static bool operator !=(Status A, Status B) { return !(A == B); }

        #endregion

        #region Public Methods

        public bool Equals(Status other)
        {
            return (this == other);
        }

        public override int GetHashCode()
        {
            return this.StatusID.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            var sta = obj as Status;
            if (sta == null)
                return false;
            else
                return this == sta;
        }

        public override string ToString()
        {
            return string.Format("StatusID:{0} CreatedAt:{1} Text:{2}", this.StatusID, this.CreatedAt.ToString(), this.Text);
        }

        #endregion
    }
    #endregion

    #region DirectMessage
    public partial class DirectMessage : TwitterData, IEquatable<DirectMessage>
    {
        #region Public Static Methods

        public static bool operator ==(DirectMessage A, DirectMessage B)
        {
            if (ReferenceEquals(A, B))
                return true;
            else if ((object)A == null || (object)B == null)
                return false;
            else
                return (A.DirectMessageID == B.DirectMessageID);
        }
        public static bool operator !=(DirectMessage A, DirectMessage B) { return !(A == B); }

        #endregion

        #region Public Methods

        public bool Equals(DirectMessage other)
        {
            return (this == other);
        }

        public override int GetHashCode()
        {
            return this.DirectMessageID.GetHashCode();
        }

        public override string ToString()
        {
            return string.Format("DmID:{0} SenderScreenName:{1} Text:{2}", this.DirectMessageID, this.SenderScreenName, this.Text);
        }

        public override bool Equals(object obj)
        {
            var dm = obj as DirectMessage;
            if (dm == null)
                return false;
            else
                return this == dm;
        }
        #endregion

    }
    #endregion

    #region TwitterList
    public partial class TwitterList : TwitterData, IEquatable<TwitterList>
    {
        #region Public Static Methods

        public static bool operator ==(TwitterList A, TwitterList B)
        {
            if (ReferenceEquals(A, B))
                return true;
            else if ((object)A == null || (object)B == null)
                return false;
            else
                return (A.TwitterListID == B.TwitterListID);
        }
        public static bool operator !=(TwitterList A, TwitterList B) { return !(A == B); }

        #endregion

        #region Public Methods

        public bool Equals(TwitterList other)
        {
            return (this == other);
        }

        public override int GetHashCode()
        {
            return this.TwitterListID.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            var list = obj as TwitterList;
            if (list == null)
                return false;
            else
                return this == list;
        }
        #endregion

    }
    #endregion
}
